﻿using MengCC.Core.Plugins;
using MengCC.Core.Works;
using System;
using System.Collections.Generic;
using System.Text;

namespace MengCC.Core.App
{
    public class AppManager
    {
        private static bool appState=false;
        private PluginManager pluginManager;
        private WorkManager workManager;


        public AppManager(PluginManager pluginManager, WorkManager workManager)
        {
            this.pluginManager = pluginManager;
            this.workManager = workManager;
        }

        public void ReStart()
        {
            lock("AppManager-AppReStart")
            {
                appState = false;
                workManager.StopAllWork();
                pluginManager.UpdatePlugins();
                pluginManager.LoadPlugins();
                appState = true;
            }
        }

        public void Start()
        {
            lock ("AppManager-AppReStart")
            {
                if (appState) return;
                ReStart();
            }
        }

        public bool IsRunning()
        {
            return appState;
        }
    }
}
